package com.openroom.ui;

import java.util.List;

import org.apache.pivot.util.Vote;
import org.apache.pivot.wtk.TabPane;
import org.apache.pivot.wtk.TabPaneSelectionListener;

import com.openroom.db.DBHelper;
import com.openroom.model.Catalog;
import com.openroom.model.Folder;
import com.openroom.model.ModelLocator;
import com.openroom.model.Photograph;

public class LeftNavComponent {

    private MainWindow mainWindow;

    public LeftNavComponent(MainWindow mainWindow) {
        super();
        this.mainWindow = mainWindow;
    }

    public void initialize() {
        mainWindow.leftTabPane.getTabPaneSelectionListeners().add(new TabPaneSelectionListener() {
            @Override
            public Vote previewSelectedIndexChange(TabPane arg0, int arg1) {
                return Vote.APPROVE;
            }

            @Override
            public void selectedIndexChangeVetoed(TabPane arg0, Vote arg1) {

            }

            @Override
            public void selectedIndexChanged(TabPane tabpane, int previousSelectedIndex) {
                switch (tabpane.getSelectedIndex()) {
//                case 0:
//                    List<Catalog> allCatalogs = DBHelper.getInstance().getAllCatalogs();
//                    if (!allCatalogs.isEmpty())
//                    {
//                        Catalog catalog = allCatalogs.get(0);
//                        Long catalogId = catalog.getCatalogId();
//                        List<Photograph> allPhotographsOfCatalog = DBHelper.getInstance().getAllPhotographsOfCatalog(
//                                catalogId);
//                        ModelLocator.getInstance().setAllPhotographsOfFolder(allPhotographsOfCatalog);
//                    }
//                    break;
//                case 1:
//                    List<Folder> getallImportedFolders = DBHelper.getInstance().getallImportedFolders();
//                    if (!getallImportedFolders.isEmpty()) {
//                        Folder folder = getallImportedFolders.get(0);
//                        List<Photograph> allPhotographsOfFolder = DBHelper.getInstance().getAllPhotographsOfFolder(
//                                folder.getFolderId());
//                        ModelLocator.getInstance().setAllPhotographsOfFolder(allPhotographsOfFolder);
//                    }
//                    break;
                default:
                    break;
                }
            }

        });
    }
}
